#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e4 + 5;
const int M = 1e9 + 7;

int t, a, b, c;

int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> a >> b >> c;
        if (a > b)
            swap(a, b);

        int dif = b - a;
        if (a <= dif && b > dif)
        {
            int m = dif * 2;
            if (c > dif * 2)
            {
                cout << -1 << endl;
            }
            else
            {
                if (c <= dif)
                {
                    cout << c + dif << endl;
                }
                else
                {
                    cout << c - dif << endl;
                }
            }
        } else {
            cout << -1 << endl;
        }
    }
    return 0;
}